package com.chixing.day17.Thread;

public class OddThread implements Runnable {
    private Thread b;
    public OddThread(Thread b) {
        this.b = b;
    }
     @Override
     public void run() {
         //奇数输出到21，让偶数线程全部执行结束（让步）
         for (int i = 1; i <= 50; i++){
             if(i % 2 != 0){
                 System.out.println("50以内奇数为： " +i);
                 System.out.println(Thread.currentThread().getName() + i);
                 if(i == 21){
                     try {
                         b.join(300);
                     } catch (InterruptedException ex) {
                         throw new RuntimeException(ex);
                     }
                 }
                 try {
                     Thread.sleep(3);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
             }
         }

     }
}
